import Taro, {Component} from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import './index.scss'
import classNames from 'classnames'
import { headImg } from '@/utils/utils'
import { toGoodsPage } from '@/utils/page_router'

interface IProps {
  info: any
  className?: string
}

export default class GoodsThreeItem extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const { info={}, className } = this.props
    return (<View className={classNames('goods-three-item', className)} onClick={() => toGoodsPage(info)}>
      <View className='img-box'>
        <Image src={headImg(info.images)} lazyLoad className='goods-img'/>
        {info.salesNumber && <View className='sold-num'>{info.salesNumber}件已售</View>}
      </View>
      <View className='goods-name t-o-e'>{info.name}</View>
      <View className='sale-price bnn-number'>￥{info.salePrice}</View>
    </View>)
  }
}
